<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>父子组件定义</title>
</head>

<body>
    <div id="app">
        <parent></parent>
    </div>
    <!-- 父组件模板 -->
    <template id="parenttem">
        <div>
            <child src="../img/1.jpg" txt="首页"></child>
        </div>
    </template>
    <!-- 子组件模板 -->
    <template id="sontem">
        <div>
            <img :src="src" />
            <br />
            <span>{{txt}}</span>
        </div>
    </template>
</body>

</html>
<script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
<script>
    new Vue({
        el: "#app",
        components: {
            "parent": {
                template: "#parenttem",
                components: {
                    "child": {
                        template: "#sontem",
                        props: ["txt", "src"]
                    }
                }
            }
        }
    })
</script>